package edu.psu.cse.siis.ic3;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class LczMain {

  public static void main(String[] args) {
    // String[] strArray_iptv = { "-apkormanifest",
    // "/Users/lczgywzyy/Desktop/phd/apk_lcz/vitamio-iptv-byr-releasea.apk", "-model",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/model", "-input",
    // "/Users/lczgywzyy/Desktop/phd/retargeted_lcz/vitamio-iptv-byr-releasea/", "-cp",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/android.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/jre/lib/rt.jar",
    // "-out", "/Users/lczgywzyy/Desktop/phd/output_lcz/", "-protobuf",
    // "/Users/lczgywzyy/Desktop/phd/protobuf_lcz/" };
    // String[] strArray_fq = { "-apkormanifest", "/Users/lczgywzyy/Desktop/phd/apk_lcz/fq.apk",
    // "-model", "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/model",
    // "-input", "/Users/lczgywzyy/Desktop/phd/retargeted_lcz/fq/", "-cp",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/android.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/jre/lib/rt.jar",
    // "-out", "/Users/lczgywzyy/Desktop/phd/output_lcz/", "-protobuf",
    // "/Users/lczgywzyy/Desktop/phd/protobuf_lcz/" };
    // String[] strArray_bdtb =
    // { "-apkormanifest", "/Users/lczgywzyy/Desktop/phd/apk_lcz/baidutieba.apk", "-model",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/model",
    // "-input", "/Users/lczgywzyy/Desktop/phd/retargeted_lcz/baidutieba/", "-cp",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/android.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/jre/lib/rt.jar",
    // "-out", "/Users/lczgywzyy/Desktop/phd/output_lcz/", "-protobuf",
    // "/Users/lczgywzyy/Desktop/phd/protobuf_lcz/" };
    // String[] strArray_bdtb_db = { "-apkormanifest",
    // "/Users/lczgywzyy/Desktop/phd/apk_lcz/baidutieba.apk", "-model",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/model", "-input",
    // "/Users/lczgywzyy/Desktop/phd/retargeted_lcz/baidutieba/", "-cp",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/android.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/jre/lib/rt.jar",
    // "-out", "/Users/lczgywzyy/Desktop/phd/output_lcz/", "-dbname", "pgdb_ic3", "-db",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/cc.properties" };
    // String[] strArray_zdp = { "-apkormanifest",
    // "/Users/lczgywzyy/Desktop/phd/apk_lcz/dianping.apk",
    // "-model", "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/model",
    // "-input", "/Users/lczgywzyy/Desktop/phd/retargeted_lcz/dianping/", "-cp",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/android.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/jre/lib/rt.jar",
    // "-out", "/Users/lczgywzyy/Desktop/phd/output_lcz/", "-protobuf",
    // "/Users/lczgywzyy/Desktop/phd/protobuf_lcz/" };
    // String[] strArray_dzdp_db =
    // { "-apkormanifest", "/Users/lczgywzyy/Desktop/phd/apk_lcz/dianping.apk", "-model",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/model",
    // "-input", "/Users/lczgywzyy/Desktop/phd/retargeted_lcz/dianping/", "-cp",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/android.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/jre/lib/rt.jar",
    // "-out", "/Users/lczgywzyy/Desktop/phd/output_lcz/", "-dbname", "pgdb_ic3", "-db",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/cc.properties",
    // "-computecomponents" };
    // String[] strArray_eleme_db =
    // { "-apkormanifest", "/Users/lczgywzyy/Desktop/phd/apk_lcz/eleme.apk", "-model",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/model",
    // "-input", "/Users/lczgywzyy/Desktop/phd/retargeted_lcz/eleme/", "-cp",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/android.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home/jre/lib/rt.jar",
    // "-out", "/Users/lczgywzyy/Desktop/phd/output_lcz/", "-dbname", "pgdb_ic3", "-db",
    // "/Users/lczgywzyy/Documents/EclipseWorkspace/ic3/ic3/src/main/resources/cc.properties",
    // "-computecomponents" };
    // String[] str_null = {};
    String apkPath = args[0];
    String apkName =
        new File(apkPath).getName().substring(0, new File(apkPath).getName().lastIndexOf("."));
    String[] strArray_eleme_db = { "-apkormanifest", apkPath, "-model", "model", "-input",
        "../phd/retargeted_lcz/" + apkName + "/", "-cp", "android.jar:rt.jar", "-out",
        "../phd/output_lcz/", "-dbname", "pgdb_ic3", "-db", "cc.properties", "-computecomponents" };
    Main.main(strArray_eleme_db);
  }

  public void testInitDB() {
    try {
      Class.forName("org.postgresql.Driver").newInstance();
      String url = "jdbc:postgresql://192.168.1.184:5432/pgdb";
      Connection con = DriverManager.getConnection(url, "postgres", "postgres");
      Statement st = con.createStatement();
      String sql = "select * from app_info";
      ResultSet rs = st.executeQuery(sql);
      while (rs.next()) {
        System.out.println(rs.getString(1));
        System.out.println(rs.getString(2));
        System.out.println(rs.getString(3));
        System.out.println(rs.getString(4));
      }
      rs.close();
      st.close();
      con.close();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException
        | SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
}
